{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}

<div class="p-3">
    <!--<form class="layui-form gg-form-bar border-x border-t">-->

    <!--<div class="layui-input-inline" style="width:150px;">-->
    <!--<select name="cert_type">-->
    <!--<option value="">请选择资质类别</option>-->
    <!--<option value="1">普通合同</option>-->
    <!--<option value="2">框架合同</option>-->
    <!--<option value="3">补充协议</option>-->
    <!--<option value="4">其他合同</option>-->
    <!--</select>-->
    <!--</div>-->
    <!--<div class="layui-input-inline" style="width:240px;">-->
    <!--<input type="text" name="keywords" placeholder="输入关键字" class="layui-input" autocomplete="off" />-->
    <!--</div>-->
    <!--<div class="layui-input-inline" style="width:150px;">-->
    <!--<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform"><i class="layui-icon layui-icon-search mr-1"></i>搜索</button>-->
    <!--<button type="reset" class="layui-btn layui-btn-reset" lay-filter="reset">清空</button>-->
    <!--</div>-->
    <!--</form>-->
    <input name="id" id="id" type="hidden" value="{$id}">
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <span class="layui-btn layui-btn-sm" title="增项资质" lay-event="add">+ 增项资质</span>
    </div>
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool'];

    function gouguInit() {
        var table = layui.table, tool = layui.tool, form = layui.form;
        var id = $("#id").val();
        layui.pageTable = table.render({
            elem: '#test',
            title: '项目列表',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', {title: '导出EXCEL', layEvent: 'LAYTABLE_EXCEL', icon: 'layui-icon-export'}],
            url: "/license/index/archive?id="+id, //数据接口
            cellMinWidth: 80,
            limit: 20,
            cols: [
                [ //表头
                    {
                        field: 'id',
                        title: '编号',
                        align: 'center',
                        width: 80
                    }, {
                    field: 'license_name',
                    title: '公司名称',
                    width: 160
                },  {
                    field: 'cert_types',
                    title: '资质类别',
                    width: 160
                },{
                    field: 'projects',
                    title: '项目名称',
                    width: 160
                },  {
                    field: 'report_name',
                    title: '上报人员',
                    minWidth: 240,
                }, {
                    field: 'report_num',
                    title: '上报次数',
                    align: 'center',
                    width: 100
                }, {
                    field: 'is_zx', title: '类型', align: 'center', width: 100, templet: function (d) {
                        var html = '<span class="layui-btn layui-btn-xs layui-bg">' + d.is_zx + '</span>';
                        return html;
                    }
                }, {
                    field: 'status', title: '状态', align: 'center', width: 100, templet: function (d) {
                        if(d.status==0){
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color: #C1C144;">' + d.status_name + '</span>';
                        }else if(d.status==1){
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color: #8a8f97;">' + d.status_name + '</span>';
                        }else if(d.status==2){
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color: #9B7536;">' + d.status_name + '</span>';
                        }else if(d.status==3){
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color:#3C9CFF;">' + d.status_name + '</span>';
                        }else if(d.status==4){
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color: #00d95a;">' + d.status_name + '</span>';
                        }
                        return html;
                    }
                },{
                    field: 'right',
                    fixed: 'right',
                    title: '操作',
                    width: 100,
                    align: 'center',
                    templet: function (d) {
                        var btn1 = '<span class="layui-btn layui-btn-xs" lay-event="edit">编辑</span>';
                        var btn2 = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span>';
                        return  btn1+btn2;
                    }
                }
                ]
            ]
        });

        //表头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var id = $("#id").val();
            if (obj.event === 'add') {
                tool.side('/license/index/archive_add?license_id=' + id);
                return;
            }
        });
        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            var id = $("#id").val();
            if (obj.event === 'edit') {
                tool.side('/license/index/archive_add?id=' + data.id+'&license_id='+id);
                return;
            }
            if (obj.event === 'del') {
                layer.confirm('确定要删除吗?', {
                    icon: 3,
                    title: '提示'
                }, function (index) {
                    let callback = function (e) {
                        layer.msg(e.msg);
                        if (e.code == 0) {
                            obj.del();
                        }
                    }
                    tool.delete("/license/index/archive_delete", {id: data.id}, callback);
                    layer.close(index);
                });
            }
        });


        //监听搜索提交
        form.on('submit(webform)', function (data) {
            layui.pageTable.reload({
                where: {
                    keywords: data.field.keywords,
                    cate_id: data.field.cate_id,
                    type: data.field.type
                },
                page: {
                    curr: 1
                }
            });
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->
